﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Common;
using AspNetCs.Model;
public partial class Master_Admin_memorial_Type : Admin_BasePage
{
    protected Memorial_Type MemorialTpe_Get = new Memorial_Type();
    protected void Page_Load(object sender, EventArgs e)
    {
        IsExit();
        if (!Page.IsPostBack)
        {
            bind();
        }
    }
    protected void bind()
    {
        GridView1.DataSource = MemorialTpe_Get.GetDataTable("");
        GridView1.DataBind();
        // Repeater1.DataSource =
        // Repeater1.DataBind();
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        GridView1.EditIndex = e.NewEditIndex;
        bind();
    }

    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        GridView1.EditIndex = -1;
        bind();
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow row = GridView1.Rows[e.RowIndex];
        int Newid = StringHelper.isNumber_int((row.FindControl("LbID") as Label).Text);
        string TypeName = (row.FindControl("TypeName_update") as TextBox).Text;
        string NewPoint = (row.FindControl("Point_update") as TextBox).Text;
        string Readme = (row.FindControl("Readme_update") as TextBox).Text;
        string NewOrder = (row.FindControl("Order_update") as TextBox).Text;
        Memorial_Type_Model md = new Memorial_Type_Model();
        md.Id = Newid;
        md.TypeName = TypeName;
        md.TypePoint = NewPoint;
        md.Readme = Readme;
        md.OrderId = StringHelper.isNumber_int(NewOrder);
        if (MemorialTpe_Get.Update(md) > 0)
        {
            ResultStr("Admin_memorial_Type.Aspx", "修改成功!");
        }
        else
        {
            ShowMsgBack("修改失败了!");
        }
        bind();


    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)//判定当前的行是否属于datarow类型的行 
        {
            //当鼠标放上去的时候 先保存当前行的背景颜色 并给附一颜色 
            e.Row.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#CCCCCC',this.style.fontWeight='';");
            //当鼠标离开的时候 将背景颜色还原的以前的颜色 
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor,this.style.fontWeight='';");
        }

    }
}
